/**
  ******************************************************************************
  * @author     Chris
  * @since      2024/6/24 23:22
  *
  * @file       pd_spi.c
  * @brief      SPI peripheral driver.
  *
  * @note       This file contains the hardware driver for the SPI.
  *
  * @warning    None.
  ******************************************************************************
  * Change Logs:
  *   Date          Author       Notes
  *   2024/6/24     Chris        the first version
  *
  ******************************************************************************
  */


#include "pd_spi.h"

static void SPI_init(SPI *this) {

}

static uint8_t SPI_swapByte(SPI *super, uint8_t dat) {
    return 0;
}

static SPI *build(GPIO **ssel, uint8_t sselSize, GPIO *sclk, GPIO *mosi, GPIO *miso) {
    SPI *spi = malloc(sizeof(SPI));

    Driver_add(spi, GEN_PERM);

    spi->ssel     = ssel;
    spi->sselSize = sselSize;
    spi->sclk     = sclk;
    spi->mosi     = mosi;
    spi->miso     = miso;

    spi->init     = &SPI_init;
    spi->swapByte = &SPI_swapByte;

    return spi;
}

const struct SPIClass SPIBuilder = {.build = &build};
